package com.zyf.school.manager.service.impl;

import com.zyf.school.manager.dao.FeesDao;
import com.zyf.school.manager.domain.Fees;
import com.zyf.school.manager.service.FeesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class FeesServiceImpl implements FeesService {

    @Autowired
    private FeesDao feesDao;

    @Override
    public int count() {
        return feesDao.selectCount(null);
    }

    @Override
    public void save(Fees fees) {
        feesDao.insert(fees);
    }

    @Override
    public Fees getFeesById(int id) {
        return feesDao.selectById(id);
    }

    @Override
    public List<Fees> queryAll(int startIndex, int pageSize) {
        return feesDao.queryPage(startIndex,pageSize);
    }

    @Override
    public void deleteById(int id) {
        feesDao.deleteById(id);
    }

    @Override
    public List<Fees> saveOrUpdate(Fees fees) {
        if (fees.getId()>0){
            feesDao.updateById(fees);
        }else{
            feesDao.insert(fees);
        }
        return this.queryAll(0,10);
    }
}
